﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ListBaiVietTheLoai.ascx.cs" Inherits="CMS.Web.ListManager.ListBaiVietTheLoai" %>
<style type="text/css">
    .divframe {background-color:white;border:1px solid #35B5CE;font-size:12px;
    height:300px;margin:2px;overflow:auto;padding:1px;width:240px;}
</style>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td valign="top" width="30%" class="Text_Normal">
            <div class="divframe">
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td>
                        <asp:TreeView ID="trvTheLoai" ExpandDepth="1" runat="server" Height="300px" Width="100%" OnTreeNodePopulate="Node_Populate" OnSelectedNodeChanged="Node_Selected">
                            <Nodes>
                                <asp:TreeNode Text="Danh mục thể loại" PopulateOnDemand="true" Value="0"/>   
                            </Nodes>     
                            <HoverNodeStyle CssClass="HoverNodeStyle"/>
                            <SelectedNodeStyle CssClass="SelectedNodeStyle"/>         
                        </asp:TreeView>
                    </td>
                </tr>               
            </table>  
            </div>  
            <table border="0" cellpadding="0" cellspacing="0" width="100%" align="center"> 
                <tr><td style="height: 10px;"></td></tr>
                <tr>
                    <td align="center">
                        <asp:Button ID="btnAddParent" runat="server" CssClass="Button" Text="Thêm mới" OnClick="btnThem_Click"></asp:Button>
                    </td>
                </tr>                
            </table>   
        </td>
        <td valign="top" width="70%">
            <table id="tdView" runat="server" border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td colspan="2" class="Title" align="left">Thông tin thể loại</td>
                </tr>
                <tr>
                    <td height="10px"></td>
                </tr>
                <tr>
                    <td class="Col_Left" width="25%">Tên thể loại:</td>
                    <td class="Col_Right" width="75%">
                        <asp:Label ID="lblName" runat="server" Width="76%"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="Col_Left">Thứ tự:</td>
                    <td class="Col_Right">
                        <asp:Label ID="lblThuTu" runat="server" Width="76%"></asp:Label>
                    </td>
                </tr>    
                <tr>
                    <td class="Col_Left">Trạng thái:</td>
                    <td class="Col_Right">
                        <asp:Label ID="lblTrangThai" runat="server" Width="76%"></asp:Label>
                    </td>
                </tr>
                <tr>                    
                    <td align="left" colspan="2" style="padding-top: 10px;">                                             
                        <asp:Button ID="btnAdd" runat="server" CssClass="Button" Width="90px" Text="Thêm mới" OnClick="btnThem_Click"></asp:Button>
                        <asp:Button ID="btnEdit" runat="server" CssClass="Button" Width="90px" Text="Chỉnh sửa" OnClick="btnEdit_Click"></asp:Button>   
                        <input type="button" class="Button" style="width:90px;" value="Xóa" onclick="Delete();"/>   
                        <asp:Button ID="btnTrangThai" runat="server" Width="90px" CssClass="Button" Text="Trạng thái" OnClick="btnTrangThai_Click"></asp:Button>
                        <input type="hidden" id="hidID" name="hidID" runat="server" value="0"/>                 
                    </td>
                </tr>            
            </table>            
        </td>       
    </tr> 
</table>

<script>
    function Delete()
    {
        var ID = $("#<%=hidID.ClientID %>").val();
        if(confirm("Bạn có thật sự muốn xóa?"))
        {
            CMS.Presenters.Presenters.ListBaiVietTheLoaiPresenter.DeleteBaiVietTheLoai(parseInt(ID), function(success)
            {      
                if (!success.value)
                {
                    alert("Thể loại đang được sử dụng. Không thể xóa!");
                    return false;
                }
                window.location = "<%=BaseUrl%>";
            });
        }
    }
</script>